if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[UrlDictionaryEntryGet]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].UrlDictionaryEntryGet
GO

CREATE PROCEDURE [dbo].[UrlDictionaryEntryGet]
	@key varchar(50)
AS

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON

-- Insert statements for procedure here
SELECT 
	CASE WHEN LEN(NewUrlValue) > 0 THEN NewUrlValue ELSE UrlValue END
FROM 
	UrlDictionary
WHERE
	CAST(UrlKey AS varbinary(50)) = CAST(@key AS varbinary(50))
	AND UrlKey = @key

GO